how a diesel locomotive works